﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace RoslynCompiler
{
    public static class DirectoryExtension
    {
        public static void CopyContent(this DirectoryInfo source, DirectoryInfo target)
        {
            if (source.Name == "bin")
                return;

            if (! Directory.Exists(target.FullName))
                Directory.CreateDirectory(target.FullName);

            foreach (FileInfo fi in source.GetFiles())
                fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);

            foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
                CopyContent(diSourceSubDir, target.CreateSubdirectory(diSourceSubDir.Name));
        }
    }
}
